Release 10.1A: OpenEdge Development:
AppBuilder
Configuring an ActiveX object instance
Because OCX controls are not native to the OpenEdge system, configuring them is a slightly more complicated process than configuring a comparable 4GL widget. AppBuilder generates a
control_load()procedure to handle generic initialization of OCX objects. That procedure performs three tasks:You must perform some number of tasks that are object-dependent. In general, you must:
- Assign a meaningful identifier to the object—or, more exactly, to its control frame. You need do nothing with the identifier (the Name property) of the OCX object itself.
- Write the
initialize-controls()procedure if you want to do special initialization.- Select the events you wish to handle for this object and create procedures to do that.
- Size and position the object image within the workspace.
The following walkthrough presumes you are placing an instance of the spin control that AppBuilder supplies in the Objects Palette. Follow these steps:
- Create a window workspace and set the Message Area property, so that the workspace will be able to display messages conveniently.
- Click on the Spin Control tool icon in the Objects Palette:
![]()
- Move your mouse cursor over a bare spot in your workspace and click to place the instance. The default size will probably be too large—temporarily resize it now:
![]()
- Note that AppBuilder’s main window displays two object identifiers. Replace the editable identifier (CtrlFrame) with one that is more meaningful in the context of your application. For this example, use iSpinBox:
![]()
![]()
- Press F2 to run the workspace momentarily, which forces AppBuilder to create the
control_load()procedure. (This is not a step you need normally take; it is included here only for the sake of the example.) Stop the run as soon as you like. Choose WindowCode Section Editor. When the editor window opens, select Procedures as the Section, and
control_loadas the procedure:
![]()
Note these lines of code:
AppBuilder creates the
COM-HANDLEidentifier by prepending the digraph “ch” to whatever identifier you assigned to the control frame object. In this case, the control frame identifier isiSpinBox, so the handle ischiSpinBox. AppBuilder initializes the handle by assigning the control frame’sCOM-HANDLEproperty.AppBuilder then uses that
COM-HANDLEto callLoadControls(), and finally inserts a generic call to the optionalinitialize-controls()routine.- Choose the New button. The New Procedure dialog box opens:
![]()
- Type in initialize-controls as the procedure name. (Be careful not to use an underscore, if you are used to writing C.) Set Type to Procedure, if necessary, and choose OK. Section Editor generates a new stub routine.
- Insert these lines of code:
Note how the code refers to the properties. The reference is not via the
COM-HANDLEvariable directly because that refers to the COM object layer in the adaptive interface, not to the ActiveX object itself. You must use an indirect reference, combining theCOM-HANDLE, OCX, and property identifiers:Note: The color-coding and all-caps appearance of certain properties, as shown here, is an artifact of the Section Editor settings.
![]()
- Change Section to Definitions and define a variable to represent the current spin value:
- Change Section to Triggers, and choose New. The dialog box will open:
![]()
- Select OCX.SpinUp and choose OK. Section Editor generates a new stub event handler. Insert these lines of code to complete it:
- Choose New again, and create a trigger for the OCX.SpinDown event. Use the same code.
Run the workspace. You should see the spin control initialized to 5, and your “Control Initialized” message:
![]()
When you operate the arrowhead buttons in the control, you should see the values change in increments of 100, to the limits –495 and 905:
![]()
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |